package com.sharefang.aproject.presenter;

import android.os.Handler;

import com.sharefang.aproject.bean.PptBean;
import com.sharefang.aproject.biz.ppt.IPptBiz;
import com.sharefang.aproject.biz.ppt.OnPptResultListener;
import com.sharefang.aproject.biz.ppt.PptBiz;
import com.sharefang.aproject.view.IPptView;

import java.util.List;

/**
 * Created by Administrator on 2016/8/15.
 */

public class GetPptPresenter {
    private IPptBiz pptBiz;
    private IPptView pptView;
    private Handler mHandler = new Handler();

    public GetPptPresenter(IPptView pptView) {
        this.pptView = pptView;
        this.pptBiz = new PptBiz();
    }

    public void getPpt(final boolean loadMore, int offset) {
        pptBiz.getPpt(loadMore, offset, new OnPptResultListener() {
            @Override
            public void onSuccess(final List<PptBean> pptBeans) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        pptView.doGetPpt(pptBeans, loadMore);
                    }
                });
            }

            @Override
            public void onFailure(final String message) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        pptView.showFailedError(message);
                    }
                });

            }
        });
    }
}
